7. Linear Algebra
==============

Work in progress. Basic linear algebra to be included here.

7.1 Simple Array Operations
-----------------------

See linalg.py in numpy folder for more.

>>> import numpy as np
>>> a = np.array([[1.0, 2.0], [3.0, 4.0]])
>>> print(a)
[[ 1.  2.]
[ 3.  4.]]

>>> a.transpose()
array([[ 1.,  3.],
[ 2.,  4.]])

>>> np.linalg.inv(a)
array([[-2. ,  1. ],
[ 1.5, -0.5]])

>>> u = np.eye(2) # unit 2x2 matrix; "eye" represents "I"
>>> u
array([[ 1.,  0.],
[ 0.,  1.]])
>>> j = np.array([[0.0, -1.0], [1.0, 0.0]])

>>> np.dot (j, j) # matrix product
array([[-1.,  0.],
[ 0., -1.]])

>>> np.trace(u)  # trace
2.0

>>> y = np.array([[5.], [7.]])
>>> np.linalg.solve(a, y)
array([[-3.],
[ 4.]])

>>> np.linalg.eig(j)
(array([ 0.+1.j,  0.-1.j]), array([[ 0.70710678+0.j        ,  0.70710678-0.j        ],
[ 0.00000000-0.70710678j,  0.00000000+0.70710678j]]))

[demo]

import numpy as np
a = np.array([[1.0, 2.0], [3.0, 4.0]])
print(a)
print(a.transpose())
print(np.linalg.inv(a))
u = np.eye(2) # unit 2x2 matrix; "eye" represents "I"
print(u)
j = np.array([[0.0, -1.0], [1.0, 0.0]])
print(np.dot (j, j)) # matrix product
print(np.trace(u))  # trace
y = np.array([[5.], [7.]])
print(np.linalg.solve(a, y))
print(np.linalg.eig(j))

[/demo]


::

Parameters:
square matrix
Returns
The eigenvalues, each repeated according to its multiplicity.
The normalized (unit "length") eigenvectors, such that the
column ``v[:,i]`` is the eigenvector corresponding to the
eigenvalue ``w[i]`` .